﻿using System;
using System.Collections.Generic;
using System.Text;
using Mighty.Common;
using System.Collections;

namespace Mighty.Brain
{
    public class HanBrain : BasicBrain
    {

        Dec my_Dec, round_Dec;


        public override HandedCard RoundTicEvent()
        {
            ArrayList possibleCards = new ArrayList();
            HandedCard return_card =new HandedCard();
            return_card.number = 0;

            foreach (HandedCard card in gameInfo.myCards)
            {
                if (card.isPossible) possibleCards.Add(card);
                if (card.isPossible && (card_pp(return_card) < card_pp(card))) return_card = card;    
            }
            if (card_pp(return_card)!=0)
                return return_card;
            else
                return (HandedCard)possibleCards[possibleCards.Count - 1];
            
        }



        public override Betting BettingTicEvent()
        {
            Betting betting = new Betting();
            
            betting.isPass = true;
            return betting;
        }
        /*
        private HandedCard LL_RoundTic(ArrayList possibleCards)
        {

        }

        private HandedCard Friend_RoundTic(ArrayList possibleCards)
        {
        }

        private HandedCard Defence_RoundTic(ArrayList possibleCards)
        {
        }
        */

        private int card_pp(Card card1)
        {
            int pp = 0;
            pp += card1.number;
            if (card1.number == 0 && card1.shape != Shape.Joker) return 0;
            try
            {
                if (card1.shape == gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].shape) pp += 15;
                if (gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].shape == Shape.Joker && card1.shape == gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].jokerTarget) pp += 15;
            }
            catch { }

            if (card1.shape ==(Shape)gameInfo.betting.giruda  ) pp += 30;
            if (card1.shape == Shape.Joker && gameInfo.roundIdx!=0) pp += 50;
            if (card1.shape == gameInfo.mighty.shape) pp += 100;
            

            return pp;
        }

        /*private HandedCard find_win()
        {
            if (gameInfo.roundCardIdx != 0)
            {
                int i;
                ArrayList suncard = new ArrayList();
                if (gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].shape != Shape.Joker)
                {
                    foreach (HandedCard card in gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].shape)
                    {
                        if (card.isUsed != false && card.shape == gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0].shape)
                            suncard.Add(card);
                    }
                }
            }
            //if(gameInfo.roundHistory[gameInfo.roundIdx].cardStack[0]

        }*/

    }
}
